package com.undsf.study7816

import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response

/**
 * Created by Arathi on 2017/8/16.
 */
abstract class BaseCrawler implements ICrawler {
    OkHttpClient httpClient

    BaseCrawler() {
        httpClient = new OkHttpClient()
    }

    def abstract crawl()

    def sendGetRequest(String url) {
        Request request = new Request.Builder()
                .url(url)
                .build()
        Response response = httpClient.newCall(request).execute()
        return response.body().string()
    }
}
